# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(bugsnag-ndk)

add_library( # Specifies the name of the library.
             bugsnag-ndk

             # Sets the library as a shared library.
             SHARED

             # Provides a relative path to your source file(s).
    jni/extra.cpp
    jni/bugsnag_ndk.c
    jni/bugsnag.c
    jni/metadata.c
    jni/safejni.c
    jni/event.c
    jni/handlers/signal_handler.c
    jni/handlers/cpp_handler.cpp
    jni/utils/crash_info.c
    jni/utils/stack_unwinder.c
    jni/utils/stack_unwinder_libunwindstack.cpp
    jni/utils/stack_unwinder_libcorkscrew.c
    jni/utils/stack_unwinder_libunwind.c
    jni/utils/stack_unwinder_simple.c
    jni/utils/serializer.c
    jni/utils/string.c
    jni/deps/parson/parson.c
             )
include_directories(
    jni
    jni/deps
    jni/external/libunwind/include
    jni/external/libunwindstack-ndk/include
             )

target_include_directories(bugsnag-ndk PRIVATE ${BUGSNAG_DIR}/assets/include)

target_link_libraries( # Specifies the target library.
                     bugsnag-ndk
                     # Links the log library to the target library.
                     libhilog_ndk.z.so)

set_target_properties(bugsnag-ndk
                      PROPERTIES
                      COMPILE_OPTIONS
                      -Werror -Wall -pedantic)

add_subdirectory(jni/external/libunwindstack-ndk/cmake)
target_link_libraries(bugsnag-ndk unwindstack)

target_link_libraries( # Specifies the target library.
                     bugsnag-ndk
                     # Links the log library to the target library.
                     libunwind.a)